/*
 Class:     AudioInfo
 Author:    Anthony L
 Desc:      Returns id3 tag info of mp3 files
*/

#include <map>
#include <vector>
#include <ctime>
#include <stdlib.h>

#ifdef WIN32
    #define ID3LIB_LINKOPTION 1
    // required for memcpy() in windows
    #include <string.h>
#endif

#include <sstream>

#include <fileref.h>
#include <tag.h>

using std::map;
using std::string;
using namespace std;

#ifndef AUDIOINFO_H
#define AUDIOINFO_H

namespace Org
{
    class AudioInfo
    {
        public:
            AudioInfo(const string);

            static bool is_audio_file(const string path) {
                return path.substr(path.length()-4) == ".mp3";
            }

            static string stringify(TagLib::uint i) {
                std::stringstream out;
                out << i;
                return out.str();
            }

            enum e_audio_type {flac, mp3, ogg, wma};
            int bitrate;
            int duration;
            e_audio_type audio_type;
            map<string, string> metadata;

        private:
            static map<string, string> tag_key_map;

            void extract_filetype(const string filepath);
            void extract_metadata(const string filepath);
            void extract_duration(const string filepath);
            void extract_bitrate(const string filepath);
            

    };
}
#endif // AUDIOINFO_H
